package com.huawei.esdk.tp.device.smc;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

import com.huawei.esdk.tp.southcommu.cxf.gen.SmcExternal2SoapSouth;

public abstract class SMCCxfClient
{
    private SmcExternal2SoapSouth smcExternal2Soap;

    protected SmcExternal2SoapSouth getSmcExternal2Soap()
    {
        return smcExternal2Soap;
    }

    protected void setSmcExternal2Soap(SmcExternal2SoapSouth smcExternal2Soap)
    {
        this.smcExternal2Soap = smcExternal2Soap;
    }

    Object invoke(String name, Object[] params) throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException{
        Class<?>[] paramTypes = new Class<?>[params.length];
        int index = 0;
        for (Object param : params)
        {
            paramTypes[index++] = param.getClass();
        }
            
        Method m = smcExternal2Soap.getClass().getMethod(name, paramTypes);
        
        return m.invoke(smcExternal2Soap, params);
    }
}
